package collection;

import java.util.*;

public class SortPoint {
    private static Object Point;

    public static void main(String[] args) {
        List<Point> list = new ArrayList<>();
        list.add(new Point(5, 8));
        list.add(new Point(15, 8));
        list.add(new Point(25, 18));
        list.add(new Point(4, 20));
        list.add(new Point(1, 4));
        list.add(new Point(22, 50));
        System.out.println("list原始数据:" + list);


        Collections.sort(list, (o1, o2) -> {
            int len1 = o1.getX() * o1.getX() + o1.getY() * o1.getY();
            int len2 = o2.getX() * o2.getX() + o2.getY() * o2.getY();
            return len2 - len1;
        });
    }
}
